package com.project.controller;

import com.project.bean.ResBean;
import com.project.bean.UserBean;
import com.project.service.IResService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RequestMapping("res")
@RestController
public class ResController {
    @Autowired
    private IResService resService;

    @RequestMapping("add")
    public String add(String title, String info, int topicId,HttpServletRequest request){
        UserBean user = (UserBean) request.getSession().getAttribute("loginUser");
        resService.add(new ResBean(title,info,topicId,user.getId()));
        return "ok";
    }
}
